import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { BoardMasterPlan, BoardCurrentMain } from "@/api/backend/index";

export const useBoardMasterPlan = defineStore(Names.BoardMasterPlan, {
  state: () => {
    return {
      single: <any>{},
      type: <any>[],
      tags: <any>{},
      showMoreForm: false,
    };
  },
  getters: {},
  actions: {
    //获取主计划看板列表数据
    getList(filter: any) {
      return new Promise((resolve, reject) => {
        _get(BoardCurrentMain + "/list", filter, "json", "")
          .then((res: any) => {
            console.log("获取主计划看板列表数据/new", res);
            resolve(res);
          })
          .catch((err: any) => {
            console.log(err);
            reject(err);
          });
      });
    },
    //获取客户名称列表
    getCustName(filter: any) {
      return new Promise((resolve, reject) => {
        _get(BoardCurrentMain + "/queryCustNameList", filter, "json", "")
          .then((res: any) => {
            console.log("获取客户名称列表", res);
            resolve(res);
          })
          .catch((err: any) => {
            console.log(err);
            reject(err);
          });
      });
    },
    //获取首工序列表
    getNewPro(filter: any) {
      return new Promise((resolve, reject) => {
        _get(BoardCurrentMain + "/queryProNameList", filter, "json", "")
          .then((res: any) => {
            console.log("获取首工序列表", res);
            resolve(res);
          })
          .catch((err: any) => {
            console.log(err);
            reject(err);
          });
      });
    },
  },
});
